package com.xiaoge.biz.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.xiaoge.biz.entity.Product;
import com.xiaoge.biz.mapper.ProductMapper;
import com.xiaoge.biz.service.ProductService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.UUID;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author xiaoge
 * @since 2021-03-21
 */
@Service
public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> implements ProductService {

    @Autowired
    private ProductMapper productMapper;

    /**
     * 添加物资
     *
     * @param product
     */
    @Override
    public void add(Product product) {
        product.setStatus(2);
        product.setPNum(UUID.randomUUID().toString().substring(0, 32));
        productMapper.insert(product);
    }

    /**
     * 查询物资库存
     *
     * @param page
     * @param queryWrapper
     * @return
     */
    @Override
    public IPage<Product> findProductStocks(Page<Product> page, QueryWrapper<Product> queryWrapper) {
        return baseMapper.findProductStocks(page, queryWrapper);
    }

    @Override
    public IPage<Product> getDetails(Page<Product> page, String inNum) {
        return baseMapper.getDetails(page, inNum);
    }

    @Override
    public IPage<Product> getOutDetails(Page<Product> page, String outNum) {
        return baseMapper.getOutDetails(page, outNum);
    }

    @Override
    public IPage<Product> findOutEnableStocks(Page<Product> page, QueryWrapper<Product> queryWrapper) {
        return baseMapper.findOutEnableStocks(page, queryWrapper);
    }
}
